<? require_once $_SERVER["DOCUMENT_ROOT"].'/frostcore/system_header.php'; 
$user = $USER->GetUserInfo();
$balance = $user['fields']['balance']['value'];

if(check_action('refill_balance')){
    $upd = $_POST['balance'];
    $value_id = $user['fields']['balance']['value_id'];
    if(is_numeric($upd) && ($upd > 0 || $USER->isAdmin())){
        $result = BDS::Update($value_id, array('value' => $upd+$balance));    
        $balance +=$upd;
    }else{
        Logger::error("Invalid number");
    }
    
}
Logger::ShowAll();
?>
<div><?=$balance?></div>
<form method="post">
    <? set_action("refill_balance"); ?>
    <input type="text" name="balance">
    <input type="submit" value="Refill">
</form>